//
//  MyAnnotation.m
//  QueryClient2
//
//  Created by  thomas on 11-2-3.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "PhotoAnnotation.h"


@implementation PhotoAnnotation
@synthesize coordinate     = _coordinate;
@synthesize annotationType = _annotationType;
@synthesize userData       = _userData;
@synthesize url            = _url;
@synthesize location       = _location;
@synthesize comments       = _comments;
@synthesize timeString     = _timeString;

-(id) initWithCoordinate:(CLLocationCoordinate2D)coordinate 
		  annotationType:(AnnotationType) annotationType
				   title:(NSString*)title
				   location:(NSString*)location
				   comments:(NSString*)comments
				   timeString:(NSString*)timeString

{
	self = [super init];
	_coordinate = coordinate;
	_title      = [title retain];
	_annotationType = annotationType;
	_location   = [location retain];
	_comments   = [comments retain];
	_timeString = [timeString retain];
	return self;
}

- (NSString *)title
{
	switch (_annotationType) {
		case AnnotationTypeCommentsLocation:
			return _comments;
			break;
		case AnnotationTypeDateLocation:
			return _timeString;
			break;
		case AnnotationTypeDateComments:
			return _timeString;
			break;			
		default:
			return _title;
			break;
	}
}

- (NSString *)subtitle
{	
	switch (_annotationType) {
		case AnnotationTypeCommentsLocation:
			return _location;
			break;
		case AnnotationTypeDateLocation:
			return _location;
			break;
		case AnnotationTypeDateComments:
			return _comments;
			break;			
		default:
			return [NSString stringWithFormat:@"%lf, %lf", _coordinate.latitude, _coordinate.longitude];;
			break;
	}
}

-(void) dealloc
{
	[_title    release];
	[_userData release];
	[_url      release];
	[_comments release];
	[_location release];
	[_timeString release];
	
	[super dealloc];
}
@end

